<template>
  <el-dialog title="施工进度信息录入" :visible.sync="dialogVisible" width="50%" :before-close="handleClose">
    <el-form :model="Progress" label-width="100px" class="demo-form-inline">
      <el-row>
        <el-col :span="12">
          <el-form-item label="开挖里程">
            <el-input v-model="Progress.excavationMileage"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="仰拱里程">
            <el-input v-model="Progress.invertMileage"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="12">
          <el-form-item label="二衬里程">
            <el-input v-model="Progress.erMileage"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="创建时间">
            <el-date-picker type="date" value-format="yyyy-MM-dd" placeholder="选择日期"
                            v-model="Progress.createTime"></el-date-picker>
          </el-form-item>
        </el-col>
      </el-row>

    </el-form>
    <span slot="footer" class="dialog-footer">
      <el-button @click="dialogVisible = false">取 消</el-button>
      <el-button type="primary" @click="create">确 定</el-button>
    </span>
  </el-dialog>
</template>

<script>
import api from '../../../api'
import qs from 'qs'

export default {
  data() {
    return {
      dialogVisible: false,
      //项目信息
      tunnelList: [],
      etypeList: [],
      Progress: {
        wId: '',
        excavationMileage: '',
        invertMileage: '',
        erMileage: '',
        createTime: ''
      }
    }
  },
  mounted() {
    this.$bus.$on('onAddSection', (flag) => {
      if (this.Progress.wId == '') {
        this.$message({
          type: 'fail',
          message: '请选择洞幅'
        })
        this.dialogVisible = false
      } else {
        this.dialogVisible = true
      }
    })
    this.$bus.$on('onAddtunnelProgressWid', (flag) => {
      this.Progress.wId = flag
    })
  },
  methods: {
    handleClose(done) {
      this.$confirm('确认关闭？')
          .then((_) => {
            done()
          })
          .catch((_) => {
          })
    },
    create() {
      api
          .tunnelProgresssave(qs.stringify(this.Progress))
          .then((res) => {
            if (res.data.code == 2001) {
              this.$message({
                type: 'success',
                message: '添加成功!'
              })
              this.dialogVisible = false
              this.$bus.$emit('onRefreshTunnelProgress', this.scetion.wId)
            } else {
              this.$message({
                type: 'fail',
                message: res.data.message
              })
            }
          })
          .catch((err) => {
          })
    }
  }
}
</script>

<style>

</style>